<extend name="_layout/main"/>
<block name="content">
    <div class="page-content">
        <!-- Page Breadcrumb -->
        <div class="page-breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a href="{:U('dashboard/index')}">系统首页</a>
                </li>
                <li>
                    <a href="{:U('user/index')}">会员管理</a>
                </li>
                <li class="active">会员充值</li>
            </ul>
        </div>
        <!-- /Page Breadcrumb -->

        <!-- Page Body -->
        <div class="page-body">
            <div class="row">
                <div class="col-xs-12 col-md-12">
                    <div class="tabbable">
                        <ul class="nav nav-tabs" id="myTab">
                            <li class="active">
                                <a href="javascript:;" aria-expanded="true">充值</a>
                            </li>
                        </ul>
                        <form id="pay_form" action="{:U('pay')}"/>
                        <input type="hidden" name="id" value="{$user.id}"/>
                        <div class="tab-content">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td width="150">ID：</td>
                                    <td>{$user.id}</td>
                                </tr>
                                <tr>
                                    <td>用户名：</td>
                                    <td>{$user.nickname}</td>
                                </tr>
                                <tr>
                                    <td>余额：</td>
                                    <td>
                                        余额：<span class="badge badge-blueberry">￥{$user.balance} </span>
                                        积分：<span class="badge badge-blueberry">{$user.integral} </span>
                                        商品券：<span class="badge badge-blueberry">{$user.coupon} </span>
                                    </td>
                                </tr>

                                <tr>
                                    <td>类型：</td>
                                    <td><select name="_type">
                                        <option value="1">积分</option>
                                        <option value="2">现金</option>
                                        <option value="0">商品券</option>
                                    </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>金额/数量：</td>
                                    <td><input type="text" name="amount" id="amount" class="form-control"
                                               style="width:100px"/><label class="badge badge-blueberry">充值填正数+， 扣除填负数-</label></td>
                                </tr>
                                <tr>
                                    <td>简要描述：</td>
                                    <td><textarea name="remark" cols="50" rows="5" class="form-control"
                                                  style="width:200px"></textarea></td>
                                </tr>

                                <tr>
                                    <td></td>
                                    <td><input type="submit" id="save_btn" value="确认操作"/><label
                                            style="color: red;"></label></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        </form>
                    </div>
                    <div class="horizontal-space"></div>

                </div>
            </div>

        </div>
        <!-- /Page Body -->
    </div>

</block>
<block name="footer">
    <script>
        $("#amount").change(function () {
            var amount = $(this).val();
            if (isNaN(amount)) {
                $(this).val(0);
            }
        });

        $("#save_btn").click(function (e) {
            e.preventDefault();
            var _this = $(this);
            var form = $('#pay_form');
            if (form.is('form')) {
                var action = form.attr('action');
                var data = form.serialize();
                $.post(action, data, function (xdata) {
                    if (xdata.status == 'success') {
                        document.location.reload();
                    }else{
                        tips(xdata.message,'danger');
                    }
                }, 'json')
            }
        })
    </script>
</block>
